package View;

import Bussiness.Delete_Action;
import Bussiness.Insert_Action;
import Bussiness.Search_Action;
import Bussiness.TableModel;
import Bussiness.Update_Action;
import Model.BangDiem;
import Model.MonHoc;
import Model.SinhVien;

import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import java.awt.Toolkit;
import java.awt.SystemColor;
import java.awt.CardLayout;

/**
 * 
 * @author Nhóm java lớp PNV2T - Nguyễn Thị Lệ Đài - Nguyễn Chí Hướng
 * 
 */
public class DiemSinhVien extends javax.swing.JFrame {

	private int ID;
	private Vector vecMonHoc = null;
	private SinhVien sv = null;
	private Vector vecHeader = null;
	private Vector vecDiem = null;
	private BangDiem diemChon = null;

	/** Creates new form DiemSinhVien */
	public DiemSinhVien(String MaSV) {
		initComponents();
		setLocation(400, 200);
		Search_Action sa = new Search_Action();
		Vector vec = sa.DanhSachSinhVien(4, 0, MaSV);
		sv = (SinhVien) vec.get(0);
		lbl_TenSinhVien.setText(sv.getTen());
		sa.Close();
		ShowMonHoc();
		ShowDiem();
	}

	public void ShowMonHoc() {
		Search_Action sa = new Search_Action();
		vecMonHoc = sa.DanhSachMonHoc();
		cbb_MonHoc.removeAllItems();
		for (int i = 0; i < vecMonHoc.size(); i++) {
			MonHoc mon = (MonHoc) vecMonHoc.get(i);
			cbb_MonHoc.addItem(mon.getTenMon());
		}
		sa.Close();
	}

	public void ShowDiem() {
		Search_Action sa = new Search_Action();
		vecDiem = sa.BangDiemSinhVien(sv.getID());

		vecHeader = new Vector();
		vecHeader.add("Môn học");
		vecHeader.add("Điểm kiểm tra");
		vecHeader.add("Điểm chuyên cần");
		vecHeader.add("Điểm thi");
		vecHeader.add("Điểm tổng kết");
		TableModel absModel = new TableModel(vecDiem, vecHeader,
				TableModel.Type_BangDiemSinhVien);

		tbl_DanhSachDiem.setModel(absModel);
		tbl_DanhSachDiem.setRowHeight(30);

		sa.Close();
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed"
	// desc=" Generated Code ">//GEN-BEGIN:initComponents
	private void initComponents() {
		ThemDiemSinhVien = new javax.swing.JDialog();
		ThemDiemSinhVien.setIconImage(Toolkit.getDefaultToolkit().getImage(DiemSinhVien.class.getResource("/Icon/QLSV.jpg")));
		jPanel2 = new javax.swing.JPanel();
		jToolBar1 = new javax.swing.JToolBar();
		btn_CapNhap = new javax.swing.JButton();
//		btn_Dong = new javax.swing.JButton();
		jSeparator1 = new javax.swing.JSeparator();
		jLabel3 = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jLabel5 = new javax.swing.JLabel();
		jLabel6 = new javax.swing.JLabel();
		jLabel7 = new javax.swing.JLabel();
		txt_ChuyenCan = new javax.swing.JTextField();
		txt_Thi = new javax.swing.JTextField();
		txt_KiemTra = new javax.swing.JTextField();
		cbb_MonHoc = new javax.swing.JComboBox();
		lbl_Ten = new javax.swing.JLabel();
		SuaDiemSinhVien = new javax.swing.JDialog();
		jPanel3 = new javax.swing.JPanel();
		jToolBar2 = new javax.swing.JToolBar();
		jLabel8 = new javax.swing.JLabel();
		btn_CapNhapSua = new javax.swing.JButton();
		jLabel9 = new javax.swing.JLabel();
//		btn_DongSua = new javax.swing.JButton();
		jSeparator2 = new javax.swing.JSeparator();
		jLabel10 = new javax.swing.JLabel();
		jLabel11 = new javax.swing.JLabel();
		jLabel12 = new javax.swing.JLabel();
		jLabel15 = new javax.swing.JLabel();
		jLabel17 = new javax.swing.JLabel();
		txt_ChuyenCanSua = new javax.swing.JTextField();
		txt_ThiSua = new javax.swing.JTextField();
		txt_KiemTraSua = new javax.swing.JTextField();
		lbl_TenSua = new javax.swing.JLabel();
		txt_MonHoc = new javax.swing.JTextField();
		jPanel1 = new javax.swing.JPanel();
		jLabel13 = new javax.swing.JLabel();
		lbl_TenSinhVien = new javax.swing.JLabel();
		jToolBar5 = new javax.swing.JToolBar();
		btn_ThemDiem = new javax.swing.JButton();
		jLabel14 = new javax.swing.JLabel();
		btn_SuaDiem = new javax.swing.JButton();
		jLabel16 = new javax.swing.JLabel();
		btn_Xoa = new javax.swing.JButton();
		jLabel18 = new javax.swing.JLabel();
		jScrollPane4 = new javax.swing.JScrollPane();
		tbl_DanhSachDiem = new javax.swing.JTable();

		ThemDiemSinhVien
				.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		ThemDiemSinhVien
				.setTitle("Th\u00eam \u0111i\u1ec3m sinh vi\u00ean ...");
		ThemDiemSinhVien.setResizable(false);
		ThemDiemSinhVien.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosed(java.awt.event.WindowEvent evt) {
				ThemDiemSinhVienWindowClosed(evt);
			}
		});

		jPanel2.setBackground(SystemColor.textHighlight);
		jToolBar1.setBackground(SystemColor.inactiveCaption);
		jToolBar1.setFloatable(false);

		btn_CapNhap.setBackground(new java.awt.Color(227, 239, 249));
		btn_CapNhap.setFont(new java.awt.Font("Times New Roman", 1, 13));
		btn_CapNhap.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/Icon/Sua.png")));
		btn_CapNhap.setText("C\u1eadp Nh\u1eadp");
		btn_CapNhap.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btn_CapNhapActionPerformed(evt);
			}
		});
		ThemDiemSinhVien.getContentPane().setLayout(new CardLayout(0, 0));

		jToolBar1.add(btn_CapNhap);

		jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel3.setText("T\u00ean Sinh Vi\u00ean : ");

		jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel4.setText("M\u00f4n H\u1ecdc : ");

		jLabel5.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel5.setText("\u0110i\u1ec3m Ki\u1ec3m Tra : ");

		jLabel6.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel6.setText("\u0110i\u1ec3m Chuy\u00ean C\u1ea7n : ");

		jLabel7.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel7.setText("\u0110i\u1ec3m Thi : ");

		txt_ChuyenCan.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_ChuyenCan.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		txt_Thi.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_Thi.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		txt_KiemTra.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_KiemTra.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		lbl_Ten.setFont(new java.awt.Font("Times New Roman", 1, 14));
		lbl_Ten.setForeground(new java.awt.Color(0, 0, 153));

		javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(
				jPanel2);
		jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout
				.setHorizontalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel6)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												txt_ChuyenCan,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												175, Short.MAX_VALUE)
										.addContainerGap())
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel7)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												52, Short.MAX_VALUE)
										.addComponent(
												txt_Thi,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												175,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap())
						.addGroup(
								jPanel2Layout
										.createParallelGroup(
												javax.swing.GroupLayout.Alignment.TRAILING,
												false)
										.addComponent(
												jSeparator1,
												javax.swing.GroupLayout.Alignment.LEADING)
										.addComponent(
												jToolBar1,
												javax.swing.GroupLayout.Alignment.LEADING,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												304, Short.MAX_VALUE))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(jLabel5)
														.addComponent(jLabel4)
														.addComponent(jLabel3))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												22, Short.MAX_VALUE)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(lbl_Ten)
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																jPanel2Layout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																		.addComponent(
																				cbb_MonHoc,
																				0,
																				175,
																				Short.MAX_VALUE)
																		.addComponent(
																				txt_KiemTra,
																				javax.swing.GroupLayout.Alignment.TRAILING,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				175,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		jPanel2Layout
				.setVerticalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addComponent(
												jToolBar1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												38,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(8, 8, 8)
										.addComponent(
												jSeparator1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(18, 18, 18)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel3)
														.addComponent(lbl_Ten))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel4)
														.addComponent(
																cbb_MonHoc,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																27,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel5)
														.addComponent(
																txt_KiemTra,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel6)
														.addComponent(
																txt_ChuyenCan,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel7)
														.addComponent(
																txt_Thi,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
		ThemDiemSinhVien.getContentPane().add(jPanel2, "name_6386813845309");
		SuaDiemSinhVien
				.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		SuaDiemSinhVien.setTitle("Th\u00eam \u0111i\u1ec3m sinh vi\u00ean ...");
		SuaDiemSinhVien.setResizable(false);
		SuaDiemSinhVien.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosed(java.awt.event.WindowEvent evt) {
				SuaDiemSinhVienWindowClosed(evt);
			}
		});

		jPanel3.setBackground(new java.awt.Color(227, 239, 249));
		jToolBar2.setBackground(new java.awt.Color(227, 239, 249));
		jToolBar2.setFloatable(false);
		jLabel8.setForeground(new java.awt.Color(227, 239, 249));
		jLabel8.setText(".....");
		jToolBar2.add(jLabel8);

		btn_CapNhapSua.setBackground(new java.awt.Color(227, 239, 249));
		btn_CapNhapSua.setFont(new java.awt.Font("Times New Roman", 1, 13));
		btn_CapNhapSua.setIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/Icon/Sua.png")));
		btn_CapNhapSua.setText("C\u1eadp Nh\u1eadp");
		btn_CapNhapSua.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btn_CapNhapSuaActionPerformed(evt);
			}
		});

		jLabel10.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel10.setText("T\u00ean Sinh Vi\u00ean : ");

		jLabel11.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel11.setText("M\u00f4n H\u1ecdc : ");

		jLabel12.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel12.setText("\u0110i\u1ec3m Ki\u1ec3m Tra : ");

		jLabel15.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel15.setText("\u0110i\u1ec3m Chuy\u00ean C\u1ea7n : ");

		jLabel17.setFont(new java.awt.Font("Times New Roman", 0, 13));
		jLabel17.setText("\u0110i\u1ec3m Thi : ");

		txt_ChuyenCanSua.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_ChuyenCanSua.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		txt_ThiSua.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_ThiSua.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		txt_KiemTraSua.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_KiemTraSua.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		lbl_TenSua.setFont(new java.awt.Font("Times New Roman", 1, 14));
		lbl_TenSua.setForeground(new java.awt.Color(0, 0, 153));
		lbl_TenSua.setText("r\u1ed3i");

		txt_MonHoc.setEditable(false);
		txt_MonHoc.setFont(new java.awt.Font("Times New Roman", 0, 13));
		txt_MonHoc.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

		javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(
				jPanel3);
		jPanel3.setLayout(jPanel3Layout);
		jPanel3Layout
				.setHorizontalGroup(jPanel3Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel3Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel15)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												txt_ChuyenCanSua,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												175, Short.MAX_VALUE)
										.addContainerGap())
						.addGroup(
								jPanel3Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(jLabel17)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												52, Short.MAX_VALUE)
										.addComponent(
												txt_ThiSua,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												175,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap())
						.addGroup(
								jPanel3Layout
										.createParallelGroup(
												javax.swing.GroupLayout.Alignment.TRAILING,
												false)
										.addComponent(
												jSeparator2,
												javax.swing.GroupLayout.Alignment.LEADING)
										.addComponent(
												jToolBar2,
												javax.swing.GroupLayout.Alignment.LEADING,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												304, Short.MAX_VALUE))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								jPanel3Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(jLabel12)
														.addComponent(jLabel11)
														.addComponent(jLabel10))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												22, Short.MAX_VALUE)
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																false)
														.addComponent(
																txt_KiemTraSua,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																175,
																Short.MAX_VALUE)
														.addComponent(
																txt_MonHoc,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																175,
																Short.MAX_VALUE)
														.addComponent(
																lbl_TenSua,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addContainerGap()));
		jPanel3Layout
				.setVerticalGroup(jPanel3Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel3Layout
										.createSequentialGroup()
										.addComponent(
												jToolBar2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												38,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(8, 8, 8)
										.addComponent(
												jSeparator2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(18, 18, 18)
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel10)
														.addComponent(
																lbl_TenSua,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel11)
														.addComponent(
																txt_MonHoc,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel12)
														.addComponent(
																txt_KiemTraSua,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel15)
														.addComponent(
																txt_ChuyenCanSua,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												jPanel3Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel17)
														.addComponent(
																txt_ThiSua,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																24,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));

		javax.swing.GroupLayout SuaDiemSinhVienLayout = new javax.swing.GroupLayout(
				SuaDiemSinhVien.getContentPane());
		SuaDiemSinhVien.getContentPane().setLayout(SuaDiemSinhVienLayout);
		SuaDiemSinhVienLayout.setHorizontalGroup(SuaDiemSinhVienLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
						javax.swing.GroupLayout.DEFAULT_SIZE,
						javax.swing.GroupLayout.PREFERRED_SIZE));
		SuaDiemSinhVienLayout.setVerticalGroup(SuaDiemSinhVienLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
						javax.swing.GroupLayout.DEFAULT_SIZE,
						javax.swing.GroupLayout.PREFERRED_SIZE));

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setTitle("\u0110i\u1ec3m h\u1ecdc c\u1ee7a sinh vi\u00ean ...");
		setResizable(false);
		jPanel1.setBackground(new java.awt.Color(227, 239, 249));
		jLabel13.setFont(new java.awt.Font("Times New Roman", 1, 20));
		jLabel13.setForeground(new java.awt.Color(204, 0, 204));
		jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
		jLabel13.setText("Danh s\u00e1ch \u0111i\u1ec3m c\u1ee7a sinh vi\u00ean");

		lbl_TenSinhVien.setFont(new java.awt.Font("Times New Roman", 1, 20));
		lbl_TenSinhVien.setForeground(new java.awt.Color(102, 0, 0));
		lbl_TenSinhVien.setText("Sinh Vi\u00ean");

		jToolBar5.setBorder(null);
		jToolBar5.setFloatable(false);
		jToolBar5.setOpaque(false);
		btn_ThemDiem.setFont(new java.awt.Font("Times New Roman", 1, 13));
		btn_ThemDiem.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/Icon/Them.png")));
		btn_ThemDiem.setText("Th\u00eam");
		btn_ThemDiem.setOpaque(false);
		btn_ThemDiem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btn_ThemDiemActionPerformed(evt);
			}
		});

		jToolBar5.add(btn_ThemDiem);

		jLabel14.setFont(new java.awt.Font("Times New Roman", 1, 14));
		jLabel14.setForeground(new java.awt.Color(187, 183, 183));
		jLabel14.setText(" | ");
		jToolBar5.add(jLabel14);

		btn_SuaDiem.setFont(new java.awt.Font("Times New Roman", 1, 13));
		btn_SuaDiem.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/Icon/edit_22.png")));
		btn_SuaDiem.setText("S\u1eeda");
		btn_SuaDiem.setOpaque(false);
		btn_SuaDiem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btn_SuaDiemActionPerformed(evt);
			}
		});

		jToolBar5.add(btn_SuaDiem);

		jLabel16.setFont(new java.awt.Font("Times New Roman", 1, 14));
		jLabel16.setForeground(new java.awt.Color(187, 183, 183));
		jLabel16.setText(" | ");
		jToolBar5.add(jLabel16);

		btn_Xoa.setFont(new java.awt.Font("Times New Roman", 1, 13));
		btn_Xoa.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/Icon/Xoa_22.png")));
		btn_Xoa.setText("X\u00f3a");
		btn_Xoa.setOpaque(false);
		btn_Xoa.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btn_XoaActionPerformed(evt);
			}
		});

		jToolBar5.add(btn_Xoa);

		tbl_DanhSachDiem.setFont(new java.awt.Font("Times New Roman", 0, 13));
		tbl_DanhSachDiem.setModel(new javax.swing.table.DefaultTableModel(
				new Object[][] { { null, null, null, null, null },
				}, new String[] { "MÃ´n", "Kiá»ƒm Tra", "ChuyÃªn Cáº§n",
						"Ä�iá»ƒm Thi", "Tá»•ng Káº¿t" }) {
			Class[] types = new Class[] { java.lang.String.class,
					java.lang.Float.class, java.lang.Float.class,
					java.lang.Float.class, java.lang.Float.class };
			boolean[] canEdit = new boolean[] { false, false, false, false,
					false };

			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		tbl_DanhSachDiem.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				tbl_DanhSachDiemMouseClicked(evt);
			}
		});

		jScrollPane4.setViewportView(tbl_DanhSachDiem);

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addGroup(
												jPanel1Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																false)
														.addGroup(
																jPanel1Layout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				jToolBar5,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE))
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																jPanel1Layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel13,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				325,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				lbl_TenSinhVien,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				171,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																jPanel1Layout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				jScrollPane4,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				542,
																				Short.MAX_VALUE)))
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addGroup(
												jPanel1Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
																.addComponent(
																jLabel13,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																40,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																lbl_TenSinhVien,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																40,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jToolBar5,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												32,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jScrollPane4,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												346,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
				javax.swing.GroupLayout.DEFAULT_SIZE,
				javax.swing.GroupLayout.PREFERRED_SIZE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
				javax.swing.GroupLayout.DEFAULT_SIZE,
				javax.swing.GroupLayout.PREFERRED_SIZE));
		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void SuaDiemSinhVienWindowClosed(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_SuaDiemSinhVienWindowClosed
		ShowDiem();
	}// GEN-LAST:event_SuaDiemSinhVienWindowClosed

	private void ThemDiemSinhVienWindowClosed(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_ThemDiemSinhVienWindowClosed
		ShowDiem();
	}// GEN-LAST:event_ThemDiemSinhVienWindowClosed

	private void btn_XoaActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btn_XoaActionPerformed
		if (tbl_DanhSachDiem.getSelectedRowCount() == 0) {
			JOptionPane.showMessageDialog(null,
					"Ban hay chon Mon Hoc ban muon xoa !", "Select Null !",
					JOptionPane.ERROR_MESSAGE);
		} else {
			int row = tbl_DanhSachDiem.getSelectedRow();
			diemChon = (BangDiem) vecDiem.get(row);

			int j = JOptionPane
					.showConfirmDialog(
							null,
							"B\u1ea1n mu\u1ed1n x\u00f3a b\u1ea3ng \u0111i\u1ec3m m\u00f4n h\u1ecdc n\u00e0y ?",
							"Delete ... !", 2);
			if (j == 0) {
				Delete_Action da = new Delete_Action();
				if (da.XoaBangDiem(diemChon.getMaSV(), diemChon.getMaMon()) == true) {
					JOptionPane.showMessageDialog(this,
							"X\u00f3a th\u00e0nh c\u00f4ng !", "Delete", 1);
					ShowDiem();
				} else {
					JOptionPane.showMessageDialog(this,
							"KhÃ´ng xÃ³a Ä‘Æ°á»£c !", "Delete", 1);
				}
				da.Close();
			}
		}
	}// GEN-LAST:event_btn_XoaActionPerformed

	private void tbl_DanhSachDiemMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_tbl_DanhSachDiemMouseClicked
		if (evt.getClickCount() == 2) {
			int row = tbl_DanhSachDiem.getSelectedRow();
			diemChon = (BangDiem) vecDiem.get(row);
			SuaDiemSinhVien.setVisible(true);
			SuaDiemSinhVien.pack();
			SuaDiemSinhVien.setLocation(400, 300);
			lbl_TenSua.setText(lbl_TenSinhVien.getText());
			txt_MonHoc.setText(diemChon.getTenMon());
			txt_KiemTraSua.setText(String.valueOf(diemChon.getDiemKiemTra()));
			txt_ChuyenCanSua
					.setText(String.valueOf(diemChon.getDiemChuyenCan()));
			txt_ThiSua.setText(String.valueOf(diemChon.getDiemThi()));
		}
	}// GEN-LAST:event_tbl_DanhSachDiemMouseClicked

	private void btn_CapNhapSuaActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btn_CapNhapSuaActionPerformed
		Double KiemTra = 0.0;
		Double ChuyenCan = 0.0;
		Double DiemThi = 0.0;

		boolean flag = true;
		try {
			KiemTra = Double.parseDouble(txt_KiemTraSua.getText());
		} catch (NumberFormatException ex) {
			JOptionPane.showMessageDialog(null, "Sai d\u1eef li\u1ec7u !",
					"Number Format !", JOptionPane.ERROR_MESSAGE);
			txt_KiemTra.requestFocus();
			flag = false;
		}
		if (flag == true)
			try {
				ChuyenCan = Double.parseDouble(txt_ChuyenCanSua.getText());
			} catch (NumberFormatException ex) {
				JOptionPane.showMessageDialog(null, "Sai d\u1eef li\u1ec7u !",
						"Number Format !", JOptionPane.ERROR_MESSAGE);
				txt_ChuyenCan.requestFocus();
				flag = false;
			}

		if (flag == true)
			try {
				DiemThi = Double.parseDouble(txt_ThiSua.getText());
			} catch (NumberFormatException ex) {
				JOptionPane.showMessageDialog(null, "Sai d\u1eef li\u1ec7u !",
						"Number Format !", JOptionPane.ERROR_MESSAGE);
				txt_Thi.requestFocus();
				flag = false;
			}
		if (flag == true) {
			diemChon.setDiemKiemTra(KiemTra);
			diemChon.setDiemChuyenCan(ChuyenCan);
			diemChon.setDiemThi(DiemThi);
			Double DiemTongKet = (ChuyenCan * 2 + KiemTra * 3 + DiemThi * 5) / 10;
			diemChon.setDiemTongKet(DiemTongKet);

			Update_Action ua = new Update_Action();
			if (ua.SuaBangDiem(diemChon) == true) {
				int j = JOptionPane
						.showConfirmDialog(
								null,
								"Sua th\u00e0nh c\u00f4ng ! B\u1ea1n c\u00f3 mu\u1ed1n sua ti\u1ebfp kh\u00f4ng ?",
								"Continue ... !", 2);
				if (j != 0) {
					ShowDiem();
					SuaDiemSinhVien.dispose();
				}
			} else {
				JOptionPane.showMessageDialog(this, "Khong sua duoc !");
			}

			ua.Close();

		}
	}// GEN-LAST:event_btn_CapNhapSuaActionPerformed

	private void btn_SuaDiemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btn_SuaDiemActionPerformed
		if (tbl_DanhSachDiem.getSelectedRowCount() == 0) {
			JOptionPane.showMessageDialog(null,
					"Ban hay chon Mon Hoc ban muon sua diem !",
					"Select Null !", JOptionPane.ERROR_MESSAGE);
		} else {
			int row = tbl_DanhSachDiem.getSelectedRow();
			diemChon = (BangDiem) vecDiem.get(row);
			SuaDiemSinhVien.setVisible(true);
			SuaDiemSinhVien.pack();
			SuaDiemSinhVien.setLocation(400, 300);
			lbl_TenSua.setText(lbl_TenSinhVien.getText());
			txt_MonHoc.setText(diemChon.getTenMon());
			txt_KiemTraSua.setText(String.valueOf(diemChon.getDiemKiemTra()));
			txt_ChuyenCanSua
					.setText(String.valueOf(diemChon.getDiemChuyenCan()));
			txt_ThiSua.setText(String.valueOf(diemChon.getDiemThi()));
		}
	}// GEN-LAST:event_btn_SuaDiemActionPerformed


	private void btn_CapNhapActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btn_CapNhapActionPerformed
		Double KiemTra = 0.0;
		Double ChuyenCan = 0.0;
		Double DiemThi = 0.0;

		boolean flag = true;
		try {
			KiemTra = Double.parseDouble(txt_KiemTra.getText());
		} catch (NumberFormatException ex) {
			JOptionPane.showMessageDialog(null, "Sai d\u1eef li\u1ec7u !",
					"Number Format !", JOptionPane.ERROR_MESSAGE);
			txt_KiemTra.requestFocus();
			flag = false;
		}
		if (flag == true)
			try {
				ChuyenCan = Double.parseDouble(txt_ChuyenCan.getText());
			} catch (NumberFormatException ex) {
				JOptionPane.showMessageDialog(null, "Sai d\u1eef li\u1ec7u !",
						"Number Format !", JOptionPane.ERROR_MESSAGE);
				txt_ChuyenCan.requestFocus();
				flag = false;
			}

		if (flag == true)
			try {
				DiemThi = Double.parseDouble(txt_Thi.getText());
			} catch (NumberFormatException ex) {
				JOptionPane.showMessageDialog(null, "Sai d\u1eef li\u1ec7u !",
						"Number Format !", JOptionPane.ERROR_MESSAGE);
				txt_Thi.requestFocus();
				flag = false;
			}
		if (flag == true) {
			BangDiem diem = new BangDiem();
			diem.setMaSV(sv.getID());
			int index = cbb_MonHoc.getSelectedIndex();
			MonHoc mon = (MonHoc) vecMonHoc.get(index);

			Search_Action sa = new Search_Action();
			if (sa.KiemTraBangDiem(sv.getID(), mon.getID()) == true) {
				JOptionPane
						.showMessageDialog(
								null,
								"Sinh Vi\u00ean "
										+ sv.getTen()
										+ " \u0111\u00e3 c\u00f3 \u0111i\u1ec3m m\u00f4n "
										+ mon.getTenMon() + " r\u1ed3i !",
								"Error !", JOptionPane.ERROR_MESSAGE);
			} else {
				sa.Close();

				diem.setMaMon(mon.getID());
				diem.setDiemKiemTra(KiemTra);
				diem.setDiemChuyenCan(ChuyenCan);
				diem.setDiemThi(DiemThi);
				Double DiemTongKet = (ChuyenCan * 2 + KiemTra * 3 + DiemThi * 5) / 10;
				diem.setDiemTongKet(DiemTongKet);

				Insert_Action ia = new Insert_Action();
				if (ia.ThemDiem(diem) == true) {
					int j = JOptionPane
							.showConfirmDialog(
									null,
									"Th\u00eam th\u00e0nh c\u00f4ng ! B\u1ea1n c\u00f3 mu\u1ed1n th\u00eam ti\u1ebfp kh\u00f4ng ?",
									"Continue ... !", 2);
					if (j != 0) {
						ShowDiem();
						ThemDiemSinhVien.dispose();
					} else {
						txt_ChuyenCan.setText("");
						txt_KiemTra.setText("");
						txt_Thi.setText("");
						cbb_MonHoc.setSelectedIndex(0);
					}
				} else {
					JOptionPane.showMessageDialog(this, "Khong them duoc !");
				}

				ia.Close();
			}
		}
	}// GEN-LAST:event_btn_CapNhapActionPerformed


	private void btn_ThemDiemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btn_ThemDiemActionPerformed
		ThemDiemSinhVien.setVisible(true);
		ThemDiemSinhVien.pack();
		ThemDiemSinhVien.setLocation(400, 300);
		lbl_Ten.setText(lbl_TenSinhVien.getText());
	}// GEN-LAST:event_btn_ThemDiemActionPerformed

	/**
	 * @param args
	 *            the command line arguments
	 */

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JDialog SuaDiemSinhVien;
	private javax.swing.JDialog ThemDiemSinhVien;
	private javax.swing.JButton btn_CapNhap;
	private javax.swing.JButton btn_CapNhapSua;
	private javax.swing.JButton btn_SuaDiem;
	private javax.swing.JButton btn_ThemDiem;
	private javax.swing.JButton btn_Xoa;
	private javax.swing.JComboBox cbb_MonHoc;
	private javax.swing.JLabel jLabel10;
	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel12;
	private javax.swing.JLabel jLabel13;
	private javax.swing.JLabel jLabel14;
	private javax.swing.JLabel jLabel15;
	private javax.swing.JLabel jLabel16;
	private javax.swing.JLabel jLabel17;
	private javax.swing.JLabel jLabel18;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JPanel jPanel2;
	private javax.swing.JPanel jPanel3;
	private javax.swing.JScrollPane jScrollPane4;
	private javax.swing.JSeparator jSeparator1;
	private javax.swing.JSeparator jSeparator2;
	private javax.swing.JToolBar jToolBar1;
	private javax.swing.JToolBar jToolBar2;
	private javax.swing.JToolBar jToolBar5;
	private javax.swing.JLabel lbl_Ten;
	private javax.swing.JLabel lbl_TenSinhVien;
	private javax.swing.JLabel lbl_TenSua;
	private javax.swing.JTable tbl_DanhSachDiem;
	private javax.swing.JTextField txt_ChuyenCan;
	private javax.swing.JTextField txt_ChuyenCanSua;
	private javax.swing.JTextField txt_KiemTra;
	private javax.swing.JTextField txt_KiemTraSua;
	private javax.swing.JTextField txt_MonHoc;
	private javax.swing.JTextField txt_Thi;
	private javax.swing.JTextField txt_ThiSua;
	// End of variables declaration//GEN-END:variables

}
